package com.thread;

/**
 * Created by on 2019/12/11.
 */
public class ThreadOne implements Runnable {
    int num = 10;
    @Override
    public synchronized void run() {

        for(int i=0;i<10;i++){

            System.out.println("打印数字:"+Thread.currentThread()+"=="+num);

            num--;

            if(num <= 0){

                System.out.println("票已经卖完!");

                return;
            }
            }
        try {
            Thread.sleep(2000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
